﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BDS3M.Admin.Controls
{
    public partial class ViewDetailNews : System.Web.UI.UserControl
    {
        public int newsid;
        public string title;
        public string description;
        public string date;
        public string alt;
        public string decodenoidung;
        public string image;
        public string summary;
        protected void Page_Load(object sender, EventArgs e)
        {
            
                if (Request.QueryString["newsid"] != null)
                {
                    newsid = Convert.ToInt32(Request.QueryString["newsid"]);
                    DataTable dt = DAL.DCollector.DBCollector.Instance.StoredSelectAllTableWhereID("tbl_News", "News_ID", newsid.ToString());
                    summary = dt.Rows[0]["News_Summary"].ToString();
                    description = dt.Rows[0]["News_Description"].ToString();
                    decodenoidung = Server.HtmlDecode(description);
                    image = dt.Rows[0]["News_Image"].ToString();
                    alt = dt.Rows[0]["News_Alt"].ToString();
                    title = dt.Rows[0]["News_TieuDe"].ToString();
                    date = dt.Rows[0]["News_Date"].ToString();
                    txtTitle.Text = title;
                    CKEditorNoidung.Text = decodenoidung;
                    txtSummary.Text = summary;
                    txtAlt.Text = alt;
                }
            
        }

        protected void lbtDelete_Click(object sender, EventArgs e)
        {
                    newsid = Convert.ToInt32(Request.QueryString["newsid"]);
                    DAL.DCollector.DBCollector.Instance.StoredProcedureDeleteByRows("tbl_News", "News_ID", newsid.ToString());
                    Response.Redirect("/Admin/Index.aspx?panel=3&sub=1");
        }
    }
}